# -*- coding: utf-8 -*-
import os
import sys
import shutil
import  time

dir_map = {
    "kernel":"/boot/",
    "epic":"/opt/epic/",
    "root":"/"
}


def record_log(level, msg):
    log_time = time.strftime('[%Y-%m-%d-%H-%M-%S]', time.localtime(time.time()))
    logfile = os.path.normpath("/opt/kernel_upgrade.log")
    fp = open(logfile, 'a+')
    if not fp:
        return
    try:
        msg = '[' + level + ']   ' + log_time + '   ' + msg
        fp.write(msg + "\n")
    except Exception, e:
        print(str(e))
    finally:
        fp.close()
    pass


def main(argv):
    print argv[0]
    current_dir = os.getcwd()
    print current_dir

    for f in os.listdir(current_dir):
        print f
        absolute_path = os.path.join(argv[1], f)
        print absolute_path
        # 如果是文件
        if os.path.isfile(absolute_path):
             print("这是文件: ", absolute_path)
        elif os.path.isdir(absolute_path):
            print("这是文件夹：", absolute_path)


if __name__ == '__main__':
    main(sys.argv)